<template style="background-color: #fff;">
	<view class="content" >
		<view class="infoGame" v-for="(item, index) in gamearr" :key="index">
				<view class="hs-left">
					<image class="gameIcon" :src="qiniu.domain+item.image" mode="aspectFill" ></image>
				</view>
				<view class="hs-center">
					<view class="hs-title">{{item.title}}<text class="hs-type">{{item.type}}</text></view>
					<!-- <text class="hs-msg">{{item.type}}</text> -->
					<text class="hs-msg">{{item.about}}</text>
				</view>
				<view class="hs-right" @click="loadgame(item.content,item.content_ios)">安装</view>
		</view>
	</view>
</template>
<script>
	
	export default {
		
		data() {
			return {
				myInfo: {},
				
				gamearr:[],
				// 七牛云相关配置
				qiniu:{
					token: '',
					domain: '',
					expires: ''
				},
				phonetype:'',  //手机型号
			}
		},
		onReady() {
			this.updateQiniuToken()
		},
		created(){
			uni.getSystemInfo({
				success: (e) => {
					console.log('手机型号',e.platform)
					this.phonetype=e.platform;
					
				}
			})
		},
		onLoad(){
			try {
				const myInfo = uni.getStorageSync('myInfo');
				if (myInfo) {
					this.myInfo = myInfo;
				}
			} catch (e) {
				console.log(e)
			}
			
			this.gameList();
			
		},
		onPullDownRefresh() {
			
			this.gameList();
		},
		methods: {
			// 获取游戏列表
			gameList:function(){
				this.$api.api.ajaxData({
					method: 'V1.Game'
					
				}, res => {
					uni.stopPullDownRefresh();
					
					if(res.code==200){
						this.gamearr=res.data.game;
						console.log('游戏数组信息',this.gamearr)
					}
					
				})
			},
			// 获取七牛云域名
			updateQiniuToken: function () {
				let timestamp = (new Date()).getTime();
				let _this = this;
				this.$api.api.ajaxData({
					method: 'V1.QiniuToken',
					uid: this.myInfo.id,
					token: this.myInfo.token,
				}, res => {
					if (res.status) {
						let expires = timestamp + res.data.expires*1000;
						this.qiniu = {
							token: res.data.token,
							domain: res.data.domain,
							expires: expires
						}
					} else {
						_this.prompt(res.msg);
					}
				})
			},
			loadgame:function(gameurl,gameurl_ios){
				if(this.phonetype=="android"){
					if(!gameurl || gameurl==""){
						uni.showToast({
							title:'暂无下载链接',
							position: 'bottom',
							icon: 'none'
						});
						return;
					}
					plus.runtime.openURL(gameurl);
				}else{
					plus.runtime.openURL(gameurl_ios);
				}
			}
		}
	}
</script>
<style lang="scss" scoped>
	@import '../../common/common.scss';
	
	.content{
		height: 100%;
		// background-color: #fff;
	}
	.infoGame{
		width: 100%;
		height:140rpx;
		padding: 20rpx 20rpx 10rpx 20rpx;
		box-sizing: border-box;
		overflow: hidden;
		.hs-left{
			width: 120rpx;
			float: left;
			margin-left: 10rpx;
			
			height: 120rpx;
			.gameIcon{
				width: 120rpx;
				height: 120rpx;
			}
		}
		.hs-center{
			width: 400rpx;
			padding: 20rpx 30rpx;
			float: left;
			.hs-title{
				width: 100%;
				font-size: 32rpx;
				line-height: 32rpx;
				color: #333;
				display: block;
				margin-top: -10rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
			.hs-type{
				font-size: 28rpx !important;
				line-height: 28rpx !important;
				margin-left: 20rpx;
				color: #999 !important;
				
			}
			.hs-msg{
				width: 100%;
				font-size: 28rpx;
				line-height: 36rpx;
				margin-top: 10rpx;
				color: #999;
				display: block;
				// overflow: hidden;
				// text-overflow: ellipsis;
				// white-space: nowrap;
				
				
				 text-overflow: -o-ellipsis-lastline;
				  overflow: hidden;
				  text-overflow: ellipsis;
				  display: -webkit-box;
				  -webkit-line-clamp: 2;
				  line-clamp: 2;
				  -webkit-box-orient: vertical;
				  
			}   
		}
		.hs-right{
			float: left;
			height: 120rpx;
			font-size: 32rpx;
			// font-weight: bold;
			color: #007AFF;
			line-height: 40rpx;
			padding-top: 40rpx;
		}
	}
</style>